package com.yunzheng.studyLeaveSystem.modules.user.user_info.servlet; /**
 * Created with IntelliJ IDEA.
 *
 * @Author: YunZheng
 * @Date: 2023/01/31/16:31
 * @Description:
 */

import com.yunzheng.studyLeaveSystem.modules.user.user_info.service.User_infoService;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet(name = "UpdateServlet", value = "/UpdateServlet")
public class UpdateServlet extends HttpServlet {
    private User_infoService user_infoService = new User_infoService();
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        HttpSession session = request.getSession();
        String phone_num = (String) session.getAttribute("phone_num");
        String signature = request.getParameter("signature");
        try {
            user_infoService.update(phone_num,signature);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        //返回个人信息页面
        request.getRequestDispatcher("/User_infoServlet").forward(request, response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }
}
